<template>
  <InlineLayout title-name="账户台账列表">
    <template #header>
      <my-form ref="ruleForm" v-model:modelValue="dataForm" :model="dataForm" :items-datas="itemsDatas">
        <my-button type="reset" title="重置" @click="reset" />
        <my-button type="search" title="查询" :loading="loading" @click="search" />
      </my-form>
    </template>

    <template #titleTools>
      <my-button type="export" title="台账导出" @click="handleExport" />
    </template>

    <my-table v-loading="loading" :columns="columns" :table-data="tableData" @selection-change="handleSelectionChange">
      <template #operation="scope">
        <!-- <el-button link type="primary" @click="updateFile(scope.row)">上传附件</el-button>
        <el-button link type="primary" @click="lookFile(scope.row)">查看附件</el-button> -->
        <my-button type="text" @click="handleDetail(scope.row)">详情</my-button>
      </template>
    </my-table>
    <template #footer>
      <pagination v-model:page="dataForm.pageNum" v-model:limit="dataForm.pageSize" :total="total" @pagination="getList" />
    </template>
  </InlineLayout>
  <!-- <fileUpDate v-model="flieShow" @handle-query="handleQuery" /> -->
  <detail v-model="isShow" :current-row="currentRow" />
</template>
<script setup lang="ts">
import { listAb05 } from '@/api/yuanshidian/ab05';
// import fileUpDate from './components/fileUpDate';
import detail from './components/detail';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const total = ref(0);
const recordShow = ref(false);
const loading = ref(false);
const ids = ref<Array<string | number>>([]);
const ruleForm = ref<ElFormInstance>();
const single = ref(true);
const multiple = ref(true);
const headers = ref({});
const fileList = ref([]);
const paramsDataObj = ref({});
const state = reactive({
  isShow: false,
  title: '',
  dataForm: {
    pageNum: 1,
    pageSize: 10
  },
  currentRow: {},
  itemsDatas: [
    { label: '单位编码', prop: 'dw01', type: 'input' },
    { label: '单位名称', prop: 'dw02', type: 'input' },
    { label: '姓名', prop: 'gr04', type: 'input' },
    { label: '证件号码', prop: 'gr02', type: 'input' }
  ],

  tableData: [],
  columns: [
    { label: '序号', type: 'index', width: '55', prop: 'index' },
    // { type: 'selection' },
    { label: '个人编号', prop: 'gr01', align: 'center' },
    { label: '身份证号码', prop: 'gr02', align: 'center', width: '180' },
    { label: '姓名', prop: 'gr04', align: 'center', width: '80' },
    { label: '个人账号', prop: 'gr03', align: 'center' },
    { label: '出生年月', prop: 'rchkFlag', align: 'center' },
    { label: '本期个人缴费', prop: 'grzh01', align: 'center' },
    { label: '本期单位划转', prop: 'grzh02', align: 'center' },
    { label: '本期单位代缴', prop: 'grzh03', align: 'center' },
    { label: '历年个人缴费', prop: 'grzh04', align: 'center' },
    { label: '历年单位划转', prop: 'rchkFlag', align: 'center' },
    { label: '历年单位代缴', prop: 'grzh06', align: 'center' },
    { label: '操作', type: 'operation', minWidth: '60px' }
  ]
});
const { itemsDatas, tableData, columns, dataForm, isShow, currentRow, title } = toRefs(state);
const handleDetail = (data) => {
  currentRow.value.id = data.id;
  isShow.value = true;
};
//列表初始化
const getList = async () => {
  loading.value = true;
  const res = await listAb05(dataForm.value);
  tableData.value = res.rows;
  total.value = res.total;
  loading.value = false;
};
/** 搜索按钮操作 */
const handleQuery = () => {
  dataForm.value.pageNum = 1;
  getList();
};

//重置
const reset = () => {
  ruleForm.value?.resetFields();
  handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection) => {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
};
/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'yuanshidian/ab05/export',
    {
      ...dataForm.value,
      // splitID: ids.value.length > 0 ? ids.value.join(',') : ''
    },
    `ab05_${new Date().getTime()}.xlsx`
  );
};
//查询
const search = () => {
  handleQuery();
};
onMounted(() => {
  getList();
});
</script>
